from django import forms
from computerstatus.models import NumberTable

# Login登录框
class LoginForm(forms.Form):
    username = forms.CharField(max_length=20,label="账号：",widget=forms.widgets.TextInput(
        attrs={'class':"form-control",'placeholder':'请输入账号',"id":'username',"style":"display:inline;width:200px;"}),)

    password = forms.CharField(max_length=20,label="密码：",widget=forms.widgets.PasswordInput(
        attrs={'class':'form-control','placeholder':'请输入密码',"id":"password","style":"display:inline;width:200px;"}),)


# Search查询表单form
class SearchForm(forms.Form):
    # t 为日期表索引
    # s 为搜索输入框
    # n 类别索引选择
    s = forms.CharField(max_length=20,label="查询：",widget=forms.widgets.TextInput(
        attrs={'class':'form-control','placeholder':"输入关键字搜索",'id':"in_keyword"}),)

    n = forms.fields.ChoiceField(choices=(('it_number',"资产编号"),('asset_name',"资产名称"),('category',"类   别"),('seat_number',"具体位置"),('flag',"盘点状态"),('asset_users',"资产使用者"),),
        widget=forms.widgets.Select(
        attrs={'class':"form-control line left",'id':'sel_ziduan'}),)

    t = forms.fields.ChoiceField(
        widget=forms.widgets.Select(
            attrs={'class': "form-control line left", 'id': 'sel_table'}), )


    # 动态的获取数据库的值
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['t'].widget.choices = NumberTable.objects.all().values_list('tab_name', 'tab_name')


class UserForm(forms.Form):
    username = forms.CharField(max_length=20,label="账号：",widget=forms.widgets.TextInput(
        attrs={'class':"form-control",'placeholder':'请输入账号',"id":'username',"style":"display:inline;width:200px;"}),)

    password = forms.CharField(max_length=20,label="密码：",widget=forms.widgets.PasswordInput(
        attrs={'class':'form-control','placeholder':'请输入密码',"id":"password","style":"display:inline;width:200px;"}),)

    password1 = forms.CharField(max_length=20, label="密码：", widget=forms.widgets.PasswordInput(
        attrs={'class': 'form-control', 'placeholder': '请输入确认密码', "id": "password",
               "style": "display:inline;width:200px;"}), )


class virtualSearchForm(forms.Form):
    # s 为搜索输入框
    # n 类别索引选择
    s = forms.CharField(max_length=20, label="查询：", widget=forms.widgets.TextInput(
        attrs={'class': 'form-control', 'placeholder': "输入关键字搜索", 'id': "search_name"}), )

    t = forms.fields.ChoiceField(choices=(
    ('v_ip', "IP地址"), ('v_mac', "MAC地址"), ('v_cpu', "CPU"), ('v_memory', "内存"), ('v_hardDisk', "硬盘"),
    ('v_Name', "主机名"),('v_system','操作系统'),('v_hostName','宿主服务器')),
                                 widget=forms.widgets.Select(
                                     attrs={'class': "form-control line left", 'id': 'search_sel'}), )
